<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./node_modules/axios/dist/axios.js"></script>
</head>
<body>
<button>发送请求</button>
<button>取消请求</button>
</body>
<script type="module">
	const btns = document.querySelectorAll("button");
	let btnCancel;
	btns[0].onclick = function () {
		btns[1].click();
		axios({
            timeout:1000,
            url:"http://zhangpeiyue.com/scoreList",
            cancelToken:new axios.CancelToken(cancel=>btnCancel=cancel)
        }).then(value=>{
			console.log(value.data)
        }).catch(err=>{
			console.log(err,axios.isCancel(err));
        })
	}
	btns[1].onclick = function () {
		if(btnCancel) btnCancel();
	}
</script>
</html>